import { createApp } from 'vue'
import 'vue-global-api'//https://www.npmjs.com/package/vue-global-api

// import ElementPlus, { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
// import 'element-plus/dist/index.css'
// import zhCn from 'element-plus/es/locale/lang/zh-cn'
// import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'nprogress/nprogress.css'

import { createPinia } from 'pinia'

import router from './router/index'
import store from './store/index'
import App from './App.vue'
import './index.scss'

import GlobalComponent from '@/components/index' //过滤器
// import filters from '@/filters' //过滤器
import utils from '@/utils' //公共方法

import WkRemoteComps from "wk-remote-vue3-comps-ts";

const app = createApp(App)

app.use(WkRemoteComps.UI.vant)
app.use(WkRemoteComps.UI.antd)
const elementPlus = WkRemoteComps.UI.elementPlus
// console.log(WkRemoteComps.UI.zhCn);

const ElementPlusIconsVue = WkRemoteComps.UI.ElementPlusIconsVue
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
// 注册全局组件
GlobalComponent.install(app)
// 注册全局公共方法
// app.config.globalProperties.$filters = filters
app.config.globalProperties.$utils = utils
app.config.globalProperties.$loading = elementPlus.ElLoading.service
app.config.globalProperties.$msgBox = elementPlus.ElMessageBox
app.config.globalProperties.$alert = elementPlus.ElMessageBox.alert
app.config.globalProperties.$confirm = elementPlus.ElMessageBox.confirm
app.config.globalProperties.$message = elementPlus.ElMessage

// app.config.errorHandler = (err) => {
//     console.log('error');
//     /* 处理错误 */
//     console.log(err);
// }

app.use(router)
app.use(store)
const pinia = createPinia()
app.use(pinia)
// app.use(ElementPlus, {
//     locale: zhCn,
// })
app.use(elementPlus, {
  locale: WkRemoteComps.UI.zhCn,
})
app.mount('#app')
